package com.wenyu.wenyuyuedu.adapter.circleAdapter;

import android.content.Context;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wenyu.wenyuyuedu.R;
import com.wenyu.wenyuyuedu.bean.circle.CircleDetailBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/3/27.
 * 我的圈子详情页一级评论下的二级评论
 */

public class CircleSecondCommentAdapter extends BaseAdapter {
    private List<CircleDetailBean.InfoBeanX.InfoBean.PCommentBean.SonCommentBean> son_comment = new ArrayList<>();
    private Context context;

    public CircleSecondCommentAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return son_comment.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        MyCircleSecondViewHolder holder = null;
        if (view == null) {
            holder = new MyCircleSecondViewHolder();
            view = View.inflate(context, R.layout.circle_secondcomment_item, null);
            holder.circle_second_content = (TextView) view.findViewById(R.id.circle_second_content);
            view.setTag(holder);
        } else {
            holder = (MyCircleSecondViewHolder) view.getTag();
        }
        if(son_comment != null){
            CircleDetailBean.InfoBeanX.InfoBean.PCommentBean.SonCommentBean sonCommentBean = son_comment.get(i);
            String comment_name = sonCommentBean.getComment_name();
            String to_comment_name = sonCommentBean.getTo_comment_name();
            String content = sonCommentBean.getContent();
            holder.circle_second_content.setText(Html.fromHtml("<b>" + "<font color = '#576b95'>" + comment_name + "</font>" + "</b>" + "<font color='#000000'>" + "回复" + "</font>" + "<b>" + "<font color = '#576b95'>" + to_comment_name + "</font>" + "</b>" +
                    "<font color='#000000'>" + ":" + "</font>" + "<font color='#000000'>" + content + "</font>"));
        }
        return view;
    }

    class MyCircleSecondViewHolder {
        TextView circle_second_content;
    }

    public void addAll(List<CircleDetailBean.InfoBeanX.InfoBean.PCommentBean.SonCommentBean> son_comment) {
        if (son_comment != null) {
            this.son_comment = son_comment;
            notifyDataSetChanged();
        }

    }
}
